package com.sunsy.authserver.rest;

import com.sunsy.authserver.beans.R;
import com.sunsy.authserver.beans.dto.LoginDto;
import com.sunsy.authserver.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;

@RestController
@RequestMapping("login")
public class LoginController {

    private LoginService loginService;

    @Autowired
    public void setLoginService(LoginService loginService) {
        this.loginService = loginService;
    }

    @PostMapping("generalLogin")
    public R generalLogin(@Valid @RequestBody LoginDto dto, HttpServletResponse response) {
        return R.ok(loginService.generalLogin(dto));
    }

}
